import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
var _excluded = ["__id", "_status"],
    _excluded2 = ["__id", "_status"];
import intl from 'utils/intl';
import { CPAAS_IAM } from 'utils/config';
import { getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
import { CODE } from 'utils/regExp';
var organizationId = getCurrentOrganizationId();
var apiPrefix = isTenantRoleLevel() ? "".concat(CPAAS_IAM, "/v1/").concat(organizationId) : "".concat(CPAAS_IAM, "/v1");
var initDS = {
  autoQuery: true,
  selection: false,
  dataKey: 'content',
  queryFields: [{
    name: 'name',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.code').d('标签编码')
  }, {
    name: 'type',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.type').d('类型'),
    lookupCode: 'CIAM.TAG_TYPE'
  } // {
  //   name: 'fdLevel',
  //   type: 'string',
  //   label: intl.get('ciam.labelManagement.model.labelManagement.level').d('层级'),
  //   lookupCode: 'CPFM.DATA_TENANT_LEVEL',
  // },
  ],
  fields: [{
    name: 'name',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.code').d('标签编码')
  }, {
    name: 'typeMeaning',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.type').d('类型'),
    lookupCode: 'CIAM.TAG_TYPE'
  }, {
    name: 'levelMeaning',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.level').d('层级'),
    lookupCode: 'CPFM.DATA_TENANT_LEVEL'
  }, {
    name: 'tag',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.tag').d('标识')
  }, {
    name: 'tagMeaning',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.tag').d('标识')
  }, {
    name: 'enabledFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.enabledFlag').d('状态'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }, {
    name: 'description',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.description').d('描述')
  }, {
    name: 'action',
    label: intl.get('ciam.labelManagement.model.kc.action').d('操作')
  }, {
    name: 'presetFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.presetFlag').d('是否内置标签'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }, {
    name: 'inheritFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.inheritFlag').d('是否可继承'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }, {
    name: 'visibleFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.visibleFlag').d('是否页面可见'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }],
  transport: {
    read: function read(_ref) {
      var params = _ref.params,
          data = _ref.data;
      return {
        url: "".concat(apiPrefix, "/labels"),
        method: 'GET',
        params: _objectSpread(_objectSpread({}, params), data)
      };
    }
  }
}; // 模态框ds

var drawerDS = {
  autoQuery: false,
  autoQueryAfterSubmit: false,
  fields: [{
    name: 'name',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.code').d('标签编码'),
    required: true,
    pattern: CODE,
    defaultValidationMessages: {
      patternMismatch: intl.get('cpaas.common.validation.code').d('大小写及数字，必须以字母、数字开头，可包含“-”、“_”、“.”、“/”')
    }
  }, {
    name: 'type',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.type').d('类型'),
    lookupCode: 'CIAM.TAG_TYPE',
    required: true
  }, // {
  //   name: 'fdLevel',
  //   type: 'string',
  //   label: intl.get('ciam.labelManagement.model.labelManagement.level').d('层级'),
  //   lookupCode: 'CPFM.DATA_TENANT_LEVEL',
  //   required: true,
  // },
  {
    name: 'tag',
    type: 'string',
    label: intl.get('ciam.labelManagement.model.labelManagement.tag').d('标识'),
    lookupCode: 'CIAM.API_TAG_TYPE'
  }, {
    name: 'enabledFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.enabledFlag').d('状态'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }, {
    name: 'inheritFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.inheritFlag').d('是否可继承'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 0
  }, {
    name: 'visibleFlag',
    type: 'boolean',
    label: intl.get('ciam.labelManagement.model.labelManagement.visibleFlag').d('是否页面可见'),
    trueValue: 1,
    falseValue: 0,
    defaultValue: 1
  }, {
    name: 'description',
    type: 'intl',
    label: intl.get('ciam.labelManagement.model.labelManagement.description').d('描述')
  }],
  transport: {
    read: function read(_ref2) {
      var data = _ref2.data;
      var id = data.id;
      return {
        url: "".concat(apiPrefix, "/labels/").concat(id),
        method: 'GET',
        data: {},
        params: {}
      };
    },
    create: function create(_ref3) {
      var data = _ref3.data;

      var _ref4 = Array.isArray(data) ? data[0] : {},
          __id = _ref4.__id,
          _status = _ref4._status,
          other = _objectWithoutProperties(_ref4, _excluded);

      return {
        url: "".concat(apiPrefix, "/labels"),
        method: 'POST',
        data: other
      };
    },
    update: function update(_ref5) {
      var data = _ref5.data;

      var _ref6 = Array.isArray(data) ? data[0] : {},
          __id = _ref6.__id,
          _status = _ref6._status,
          other = _objectWithoutProperties(_ref6, _excluded2);

      return {
        url: "".concat(apiPrefix, "/labels"),
        method: 'PUT',
        data: other
      };
    }
  }
};
export { initDS, drawerDS };